const defaultAvatarUrl = 'https://static-1253855093.file.myqcloud.com/images/avatar-placeholder.png'

Page({
  data: {
    avatarUrl: defaultAvatarUrl,
    nickName: '李雷',
    metrics: [
      { value: 10, label: '可求助好友' },
      { value: 10, label: '可提供帮助' },
      { value: 0, label: '获得点赞' },
    ],
  },

  onChangeAvatar() {
    wx.chooseImage({
      count: 1,
      sizeType: ['compressed'],
      sourceType: ['album', 'camera'],
      success: (res) => {
        const [avatarUrl] = res.tempFilePaths
        if (avatarUrl) {
          this.setData({ avatarUrl })
        }
      },
      fail: (err) => {
        console.log('选择头像失败', err)
      },
    })
  },

  onInputChange(e) {
    this.setData({
      nickName: e.detail.value,
    })
  },
})
